<meta charset="utf-8">
<input value = "2017-12-27" id="d1"/>
<script>
    var s = d1.value;
    var firstindex = s.indexOf("-");
    var lastindex = s.indexOf("-",firstindex+1);
    //alert(lastindex);
    var y = s.substring(0,firstindex);
    var m = s.substring(firstindex+1,lastindex);
    var d = s.substring(lastindex+1);
    alert(y);
    alert(m);
    alert(d);
</script>